package com.atguigu.gmall.payment.controller;

import com.atguigu.gmall.oms.entity.OrderEntity;
import com.atguigu.gmall.payment.service.PayService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@RequestMapping
public class PayController {
    @Autowired
    PayService payService;

    @ApiOperation("跳转到待支付页面")
    @GetMapping("pay.html")
    public String toPay(@RequestParam("orderToken")String orderToken, Model model){
        //根据orderToken查询订单数据：如果经常使用orderToken  并且数据量较大，可以为orderToken创建唯一键索引
        OrderEntity orderEntity = payService.toPay(orderToken);
        model.addAttribute("orderEntity",orderEntity);

        return "pay";
    }
}
